//输入哪一年哪一月，输出有多少天
#include<stdio.h>
int the_year(int y)
{
	if((y%4==0&&y%100!=0)||(y%400==0))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int the_days(int y,int m)
{
	int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int day;
	day=a[m];
	if(the_year(y)&&m==2)
	{
		day+=1;
	}
	return day;
}
int main()
	{
		int y=0,m=0;
		scanf("%d %d",&y,&m);
		int days=the_days(y , m);
		printf("%d",days);
		return 0;
	}